<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<style>
			.active {
				color: red;
			}
		</style>
	</head>
	<body>
		<div class="box">我是box</div>

		<script>
			var boxEl = document.querySelector('.box')

			var h2El = document.createElement('h2')
			h2El.innerHTML = '我是h2'
			h2El.classList.add('active')

			// boxEl.prepend(h2El)
			// boxEl.append(h2El)
			// boxEl.after(h2El)
			// boxEl.before(h2El)
			boxEl.replaceWith(h2El)
		</script>
	</body>
</html>
